package com.mali.malibackendlog.listener;

import com.mali.malibackendlog.service.OperationService;
import com.mali.malibackendmodel.dto.OperationLogDTO;
import com.mali.malibackendmodel.pojo.Operation;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**1
 * @Author:吴键霏
 * @Date：2024/6/18 15:50
 * @Version 1.0
 */
@Component
@RocketMQMessageListener(topic = "productLog",consumerGroup = "productConsumer-group")
public class LogListener implements RocketMQListener<OperationLogDTO> {
    @Autowired
    private OperationService operationService;

    @Override
    public void onMessage(OperationLogDTO operationLogDTO) {
        Operation operation = new Operation();
        BeanUtils.copyProperties(operationLogDTO,operation);
        operationService.save(operation);
    }
}
